﻿//显示视频面板
function btnShiPin() {
    showTool();
    var tools = getTools();

    var html = "";
    html += "<div class='d_z adtitle clearfix'><div class='adfl dw30'>插入视频</div><div class='adfr adfwn dw60 adtar'><span class='d_z adbtn adbgcred' data-f='shipinqueding()'>确定</span><span class='d_z adbtn' data-f='webzifanhui()'>返回</span></div></div>";

    //<iframe height=300 width='100%' src=\"http://player.youku.com/embed/XMTM3MDcxNTA2MA==\" frameborder=0 allowfullscreen></iframe>

    //placehoder='请长按此粘贴!'
    html += "<textarea class='d_z adtextarea' placeholder='请长按此粘贴!'></textarea></br>";
    html += "注意：长按视频地址框粘贴视频地址<br/>";
    html += "<span class='d_z adbtn' data-f='shipinyouku()'>优酷例子</span><span class='d_z adbtn' data-f='shipinqingkong()'>清空</span>";
    html += "";

    html += "<div class='d_z adcontent'>请插入优酷，土豆，腾讯等网站的通用代码，以<font color=\"red\">&lt;iframe</font>开头。<hr>";
    html += "步骤：</br>";
    html += "1、在电脑上打开优酷视频，点开分享右边的箭头，复制通用代码</br>";
    html += "2、把代码发到手机上，比如发到手机QQ，再到手机上复制代码，粘贴到此处</br><hr></div>";

    tools.html(html);
    bindButtonClickEvent();
}

//视频清空
function shipinqingkong() {
    var content = getContent();
    content.val("");
}

//优酷的例子
function shipinyouku() {
    var content = getContent();
    content.val("<iframe height=300 width='100%' src=\"http://player.youku.com/embed/XMTM3MDcxNTA2MA==\" frameborder=0 allowfullscreen></iframe>");
}


//视频确定
function shipinqueding() {
    hideMenu();

    var content = getContent();
    var text = content.val();

    //<embed src="' + text + '" allowFullScreen="true" quality="high" width="100%" height="300" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>
    if (text.indexOf("iframe")!=-1) {
        var span = $('<div>'+text+'</div>');

        //插入内容
        G_CLICKELEMENT.before(span);
        bindElementClickEvent(span, elementClickEvent);

        return;
    }

    //两种新式
    if (text.indexOf("http")!=-1) {
        var span = $('<div><embed src="' + text + '" allowFullScreen="true" quality="high" width="100%" height="300" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed></div>');

        //插入内容
        G_CLICKELEMENT.before(span);
        bindElementClickEvent(span, elementClickEvent);

        return;
    }
}
